/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package Fifth;

/**
 *
 * 在另一个类中的main方法中测试上述类。main方法中分别使用三个构造方法创建三个多边形对象，使用上述对应方法计算并输出每个对象的周长和面积。
 *
 * @author 
 */
import java.util.Scanner;

public class Duomain {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        //构建长度为三的对象数组
        Duobianxing[] list = new Duobianxing[3];
        for (int i = 0; i < 3; i++) { //为数组赋值
            System.out.println("选择哪种多边形");
            int k = scanner.nextInt();
            if (k == 1) {
                list[i] = new Duobianxing();
            }
            if (k == 2) {
                System.out.println("输入边数和边长");
                list[i] = new Duobianxing(scanner.nextInt(), scanner.nextDouble());
            }
            if (k == 3) {
                System.out.println("输入边数、边长、XY坐标");
                list[i] = new Duobianxing(scanner.nextInt(), scanner.nextDouble(), scanner.nextDouble(), scanner.nextDouble());
            }
        }
        for (int i = 0; i < 3; i++) {  //输出多边形的数据
            System.out.println("多边形" + i + "的周长是:" + list[i].Zhouchang(list[i]) + "\t" + "多边形" + i + "的面积是" + list[i].area(list[i]));
        }

    }
}
